
var vue = new Vue({
	
	el : '#material_app',
	data:{
		uploadUrl : COMMON_URL.URL+'/material/upload',
		tip1 : '只能上传是 jpg、mp4 格式文件!',
		tip2 : '文件大小不能超过 500MB!',
		tip : '只能上传是 jpg、mp4 格式文件,且文件大小不能超过 500MB!',
		fileList : []
	},
	methods : {
		// 上传成功后的回调
	    uploadSuccess (response, file, fileList) {
	      this.fileList = fileList;
	      this.$notify({
	          title: '成功',
	          message: response,
	          type: 'success'
	        });
	    },
	    // 上传错误
	    uploadError (err, file, fileList) {
	      this.fileList = fileList;
	      this.$notify.error({
	          title: '错误',
	          message: '上传失败，请重试！',
	          duration: 0
	        });
	    },
	    // 上传前对文件的大小/类型的判断
	    beforeAvatarUpload (file) {
	      const extension1 = file.name.split('.')[1] === 'jpg';
	      const extension2 = file.name.split('.')[1] === 'mp4';
	      const extension3 = file.name.split('.')[1] === 'jpeg';
	      const extension4 = file.name.split('.')[1] === 'MP4';
	      const extension5 = file.name.split('.')[1] === 'JPG';
	      const extension6 = file.name.split('.')[1] === 'JPEG';
	      const isLt2M = file.size / 1024 / 1024 < 530;
	      
	      if (!extension1 && !extension2 && !extension3
	    		  && !extension4 && !extension5 && !extension6) {
	        this.$notify({
	            title: '警告',
	            message: this.tip1,
	            type: 'warning'
	          });
	      }
	      if (!isLt2M) {
	        this.$notify({
	            title: '警告',
	            message: this.tip2,
	            type: 'warning'
	          });
	      }
	      return extension1 || extension2 || extension3
	      || extension4|| extension5|| extension6&& isLt2M;
	    }
	}
	
});